package com.viknix.threadpool.manager.http.interceptor;

import com.viknix.threadpool.manager.http.model.RequestHttpEntity;
import com.viknix.threadpool.manager.http.request.HttpClientRequest;
import com.viknix.threadpool.manager.http.response.HttpClientResponse;

import java.net.URI;

/**
 * @Author: Dongqi
 * @Date: 2021/11/22 10:57
 * @Version 1.0
 * @Description: Intercepts client-side HTTP requests. Implementations of this interface can be.
 */
public interface HttpClientRequestInterceptor {
    
    /**
     * is intercept.
     *
     * @param uri uri
     * @param httpMethod http method
     * @param requestHttpEntity request entity
     * @return boolean
     */
    boolean isIntercept(URI uri, String httpMethod, RequestHttpEntity requestHttpEntity);
    
    /**
     * if isIntercept method is true Intercept the given request, and return a response Otherwise,
     * the {@link HttpClientRequest} will be used for execution.
     *
     * @return HttpClientResponse
     */
    HttpClientResponse intercept();
}
